#ifndef _MY_WIFI_H
#define _MY_WIFI_H

#include <stdlib.h>

/*
char mywifi_ssid[32]   char=uint8_t
char mywifi_pswd[64]   char=uint8_t

开启wifi前需要初始化nvs，调用下面注释的代码开启nvs_flash
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);
*/

typedef enum wifi_state_e {
    nostart_wifi = 0,
    connect_failed_wifi,
    connecting_wifi,
    connect_success_wifi,
} wifi_state_t;

#define _BIT(x) (1 << x)

void modify_wificonfig_ssid(const char* pswd);
void modify_wificonfig_pswd(const char* pswd);

esp_err_t store_wificonfig_to_nvs(void);
esp_err_t set_wifi_config_from_nvs(void);




uint8_t wifi_init(void);
uint8_t wifi_is_inited(void);
void start_sta_wifi(void);
void set_wifi_state(wifi_state_t state);
wifi_state_t get_wifi_state(void);
wifi_state_t wifi_wait_result(uint32_t wait_bits,  uint32_t overtime);




#endif